<?php
/**
 * Created by PhpStorm.
 * User: helloxingtongshi
 * Date: 2016-05-20
 * Time: 16:17
*/

    //接收数据
    $materialname =@$_POST['materialname'];
    $producename =@$_POST['producename'];



//使用require语句包含并执行sql.php
require 'sql.php';
//将材料内容显示到下拉菜单
//从material表中遍历id与name,num，数据存储于二维数组$nmaterial。
$select1 = "select materialId,materialname,num from material";
$aresult1 = mysql_query($select1);
while ($rowa= mysql_fetch_row($aresult1)) {
   $nmaterial[] =  $rowa;
}
//将商品内容显示在下拉菜单
//从produce表中遍历id与name,num,neednum，数据存储于二维数组$nproduce。
$select2 = "select id,name,num,neednum from produce";
$aresult2 = mysql_query($select2);
while ($rowl = mysql_fetch_row($aresult2)) {
    $nproduce[] = $rowl;
}

//得到材料库存余额
//将material表中遍历的num进行算总和的计算
$select3 = "select sum(num) from material where materialname='{$materialname}'";
$mnumb = mysql_query($select3);
while ($rowb = mysql_fetch_row($mnumb)) {
    $mnum = $rowb;
}
foreach( $mnum as $valueb){
}
//将produce表中遍历的neednum进行算总和的计算
$select4 = "select sum(neednum) from produce where materialname='{$materialname}'";
$mnumc = mysql_query($select4);
while ($rowc = mysql_fetch_row($mnumc)) {
    $musenum = $rowc;
}
foreach( $musenum as $valuec) {
}


//得到商品库存余额
//将produce表中遍历的num进行算总和计算-总量
$select5 = "select sum(num) from produce where name='$producename'";
$pnumb = mysql_query($select5);
while ($rowd = mysql_fetch_row($pnumb)) {
    $pnum = $rowd;
}
foreach( $pnum as $valued){
  
}
//将client表中遍历的num进行算总和的计算-已使用
$select6 = "select sum(num) from client where producename='$producename'";
$pnume = mysql_query($select6);
while ($rowe = mysql_fetch_row($pnume)) {
    $pusenum = $rowe;
}
foreach( $pusenum as $valuee) {
   
}


?>